home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_05 / tsai / pstate.cpp < prev    next >
Encoding:
Text File  |  1994-03-01  |  1.3 KB  |  60 lines

  1.  
  2. Listing 8: Function Pstatement::parse()
  3.  
  4. BOOL Pstatement::parse()
  5. {
  6.  BOOL result;
  7.  Token * pTemp;
  8.  
  9.  pTemp = gpTokenizer->getToken();  // get a new token
  10.  
  11.  switch (pTemp->tokentype)   // differentiate commands
  12.  {
  13.         .
  14.         .
  15.  case tkif:
  16.        Pif * pMyIf = new Pif;  // create a if parse node
  17.        PARSE(pMyIf)  // call the parse function and clean up
  18.        break;
  19.  case tkcall:
  20.        Pcall * pMyCall = new Pcall;   // create a call parse node
  21.        PARSE(pMyCall)      // call the parse function and clean up
  22.        break;
  23.  case tkcase:
  24.        Pcase * pMyCase = new Pcase;
  25.        PARSE(pMyCase)
  26.        break;
  27.  case tkdialog:
  28.        Pdialog * pMyDialog = new Pdialog;
  29.        PARSE(pMyDialog)
  30.        break;
  31.  case tkfor:
  32.        Pfor * pMyFor = new Pfor;
  33.        PARSE(pMyFor)
  34.        break;
  35.  case tkgoto:
  36.        PgoTo * pMyGoTo = new PgoTo;
  37.        PARSE(pMyGoTo)
  38.        break;
  39.  case tkgosub:
  40.        PgoSub * pMyGoSub = new PgoSub;
  41.        PARSE(pMyGoSub)
  42.        break;
  43.         .
  44.         .
  45.  case tkend:
  46.  case tkendif:
  47.  case tkendfor:
  48.  case tkendcase:
  49.  case tkelse:
  50.        result = TRUE;
  51.        break;
  52.  default:result = FALSE;
  53.        gpErrorFile->raise(10);   // gpErrorFile is a class to handle errors
  54.        break;
  55.  } // end of switch
  56.  
  57.  return result;
  58. }
  59.  
  60.